package com.dl.test.controller;

import com.dl.test.interceptor.MybatisInterceptor;
import com.dl.test.pojo.User;
import com.dl.test.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author DL
 * @create 2022-06-04 15:02
 */
@RestController
@RequestMapping("/my")
public class MybatisController {

    @Resource
    private UserService userService;

    @Resource
    private MybatisInterceptor mybatisInterceptor;

    @RequestMapping("/test")
    public void test(){
        System.out.println("mybatisInterceptor = " + mybatisInterceptor);
    };


    @GetMapping("/getAll")
    public List<User> getAllUser(){
        List<User> userList = userService.getUsers();
        System.out.println("userList = " + userList);
        return userList;
    }

    @GetMapping("/getUser/{userId}")
    public User getUser(@PathVariable String userId){
        User user = userService.getUserByUserId(userId);
        System.out.println("user = " + user);
        return user;
    }


}
